package com.hbnu.exercise.net;

import java.io.*;
import java.net.Socket;

public class TcpClientDemo04
{
    public static void main(String[] args)
    {
        try
        {
            Socket socket = new Socket("127.0.0.1", 8888);

            BufferedReader bufferReader = new BufferedReader(new FileReader(".\\src\\jdbc.properties"));
            PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

//            long time = System.currentTimeMillis();
//            DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
//            dataOutputStream.writeLong(time);

            String line = null;
            while ((line = bufferReader.readLine()) != null)
            {
                out.println(line);
            }

//            out.println(time);

            socket.shutdownOutput();

            String result = in.readLine();
            System.out.println(result);

            bufferReader.close();
            socket.close();
        } catch (IOException e)
        {
            e.printStackTrace();
        }


    }
}
